using System;
using System.Linq;
using Newtonsoft.Json;

namespace Close.io.API
{
	public class Builder
	{


		protected string GetJsonFieldName(Type target,string name)
		{


			var memberInfo = target.GetMembers().FirstOrDefault(t => t.Name.Equals(name));

			if(memberInfo==null) return null;

			var attributes = System.Attribute.GetCustomAttributes(memberInfo);

			return attributes.OfType<JsonPropertyAttribute>()
				.Select(propertyAttribute => propertyAttribute.PropertyName)
				.FirstOrDefault();
		}
	}
}